/******************************************************************************
 * @file     OTA.h
 * @brief    OTA线程
 * @author   Ruilist
 * @date     2025-08-18
 * @version  V1.0.0
 * @copyright Copyright (c) 2025
 *
 * @note     1 tab = 4 space
 *
 * @par 日志:
 * - V1.0.0 2025-08-18 Ruilist
 *****************************************************************************/

#ifndef __OTA_H
#define __OTA_H

//******************************** Includes *********************************//

#include <stdint.h>
#include <stdio.h>

#include "main.h"
#include "cmsis_os.h"
#include "Freertos.h"
#include "task.h"
#include "ymodem.h"
#include "queue.h"
#include "usart.h"
#include "gpio.h"
#include "elog.h"
#include "semphr.h"
#include "W25Q_Handler.h"
#include "AT24Cxx_Driver.h"

//******************************** Includes *********************************//

//******************************** Defines **********************************//

#define BUFFER_SIZE 1030

//******************************** Defines **********************************//

extern QueueHandle_t     Queue_OTA_cmd;
extern QueueHandle_t     Queue_data_buffer;
extern SemaphoreHandle_t xMutex;

extern osThreadId_t         OTA_taskHandle;
extern const osThreadAttr_t OTA_task_attributes;

// extern uint32_t g_packet_length;
typedef enum
{
    wait_req_download = 0,
    ota_download,
    wait_req_update,
    ota_end
} ota_state_t;

//*********************Thread_Func **********************//

extern void ota_task( void *argument );

//*********************Thread_Func **********************//

//*********************Queue_Handler ********************//

//*********************Queue_Handler ********************//

//******************************** Declaring ********************************//

//******************************** Declaring ********************************//

#endif  // End of __OTA_H
